/***************************************************************************
** @file:		spi.h
** @brief:  	
** @author:	
** @date:		2019-7-25
** @version: 	
***************************************************************************/
#ifndef __SPI_H__
#define __SPI_H__

#include "types.h"
#include <reg52.h>

typedef struct 
{
    void (*gpio_init)(void);
    void (*n_cs_pin_set)(uint8_t val); 
    void (*sclk_pin_set)(uint8_t val); 
    void (*mosi_pin_set)(uint8_t val);
    void (*miso_pin_set)(uint8_t val); 
    uint8_t (*miso_pin_read)(uint8_t val);  
    uint8_t (*mosi_pin_read)(uint8_t val);  
}spi_pin_ops_t;


typedef struct 
{
    uint8_t mode;
    spi_pin_ops_t ops;
}spi_dev_t;

extern void spi_init(spi_dev_t dev);
extern uint8_t spi_read_write_byte(spi_dev_t dev,uint8_t val);


#endif  /*  __SPI_H__  */

